DOC Skip to main content

Recommended Filter List

Update on 2026-08-11 03:43:04

ON THIS PAGE

1. Quick Start

#include <libobsensor/ObSensor.hpp>

ob::Pipeline pipe;

auto device = pipe.getDevice();

// Step 1: Get the target Sensor (using depth stream as an example)

auto sensor = device->getSensor(OB_SENSOR_DEPTH);

// Step 2: Get the Recommended Filter List

auto filters = sensor->createRecommendedFilters();

// Step 3: Check if there are recommended Filters

if(filters.empty()) {

    std::cout << "This Sensor does not support recommended post-processing. Use the raw frames directly." << std::endl;

    return 0;

}

// Step 4: View the initial enabled state of each Filter

for(auto &filter : filters) {

    std::cout << filter->getName()

              << " : " << (filter->isEnabled() ? "enabled" : "disabled")

              << std::endl;

}

// Step 5: Start the data stream

std::shared_ptr<ob::Config> config = std::make_shared<ob::Config>();

config->enableVideoStream(OB_STREAM_DEPTH);

pipe.start(config);

while(true) {

    auto frameSet = pipe.waitForFrameset(100);

    if(!frameSet) continue;

    auto depthFrame = frameSet->getFrame(OB_FRAME_DEPTH);

    if(!depthFrame) continue;

    // Step 6: Apply enabled Filters in sequence

    std::shared_ptr<ob::Frame> outFrame = depthFrame;

    for(auto &filter : filters) {

        if(filter->isEnabled()) {

            auto result = filter->process(outFrame);

            if(result) outFrame = result;

        }

    }

    // outFrame is the processed depth frame

}

⚠ Note: The Recommended Filter List is bound to the stream type of the Sensor it was obtained from. It can only process frames of that type. For example, the list obtained from a depth Sensor can only process depth frames. Passing in other frame types will cause processing failures or return `nullptr`.

2. Viewing and Adjusting the Recommended List

Step 1: View the Recommended Filter List

auto filters = sensor->createRecommendedFilters();

std::cout << "Recommended Filter List (" << filters.size() << " filters):" << std::endl;

for(auto &filter : filters) {

    std::cout << "  - " << filter->getName()

              << "  [" << (filter->isEnabled() ? "enabled" : "disabled") << "]"

              << std::endl;

}

Step 2: View a Filter's Configurable Parameters

Once you have identified the target Filter, use getConfigSchemaVec() to see which parameters it supports, along with their ranges and default values:

Field

Description

name

Parameter name

type

Parameter type ("int" / "float" / "bool")

min

Minimum value

max

Maximum value

step

Step size

def

Default

desc

Description

// Using TemporalFilter as an example, view its configurable parameters

for(auto &filter : filters) {

    if(filter->getName() == "TemporalFilter") {

        for(auto &item : filter->getConfigSchemaVec()) {

            std::cout << "  " << item.name

                      << "  type=" << item.type

                      << "  range=[" << item.min << ", " << item.max << "]"

                      << "  step=" << item.step

                      << "  default=" << item.def

                      << std::endl;

        }

        break;

    }

}

Step 3: Read Current Parameter Values

getConfigSchemaVec() returns the static parameter definitions (range, default value), while getConfigValue() returns the actual runtime value currently in effect.

for(auto &filter : filters) {

    if(filter->getName() == "TemporalFilter") {

        double diffScale = filter->getConfigValue("diff_scale");

        double weight    = filter->getConfigValue("weight");

        std::cout << "diff_scale=" << diffScale

                  << "  weight=" << weight << std::endl;

        break;

    }

}

Step 4: Modify Parameters

Method 1: Generic Approach (recommended) — suitable for runtime dynamic adjustment without needing to know the Filter's concrete type:

for(auto &filter : filters) {

    if(filter->getName() == "TemporalFilter") {

        filter->setConfigValue("diff_scale", 0.1);

        filter->setConfigValue("weight", 0.4);

        break;

    }

}

Method 2: Strongly-Typed Approach — use is<T>() to check the type, as<T>() to cast to the subclass, and call the specific API. IDEs provide autocompletion for this approach.

for(auto &filter : filters) {

    if(filter->is<ob::TemporalFilter>()) {

        auto temporalFilter = filter->as<ob::TemporalFilter>();

        temporalFilter->setDiffScale(0.1f);

        temporalFilter->setWeight(0.4f);

    }

}

Step 5: Enable / Disable a Filter

for(auto &filter : filters) {

    if(filter->getName() == "TemporalFilter") {

        filter->enable(false);  // Temporarily disable temporal filtering

    }

}

Important Notes

• The default parameter values for each Filter in the recommended list are the SDK's optimal configuration for the currently connected device. Using them directly typically yields good results.

• To restore default values, simply call sensor->createRecommendedFilters() again. The parameters will be reset to the device defaults.

3. Different Sensors Return Different Lists

⚠ Note: The Recommended Filter List is bound to the stream type of the Sensor it was obtained from. Filters in the list can only process frames of the matching stream type. Ensure the frame type passed to the Filter matches the Sensor's stream type. See the notes in Section 3.1 for details.

Different Sensor stream types return different Filter lists: the depth Sensor returns depth-specific Filters, and the color Sensor returns color-specific Filters.

// Depth stream recommended Filters

auto depthSensor  = device->getSensor(OB_SENSOR_DEPTH);

auto depthFilters = depthSensor->createRecommendedFilters();

// Color stream recommended Filters

auto colorSensor  = device->getSensor(OB_SENSOR_COLOR);

auto colorFilters = colorSensor->createRecommendedFilters();

Different device models may also return different list contents. Always look up Filters by name using filter->getName(), and never hardcode index positions.

// Correct approach: look up by name

for(auto &filter : filters) {

    if(filter->getName() == "ThresholdFilter") { /* ... */ }

}

// Wrong approach: hardcoded index (order may differ across devices)

// auto thresholdFilter = filters[2];  // Do NOT do this

4. Comparison and Recommendations

 

Create Filter Directly

Recommended Filter List

Ease of Use

Requires understanding of each Filter's purpose and parameters

No detail knowledge needed, works out of the box

Parameter Configuration

Manual setup, fully controllable

Device-optimal defaults, fine-tune as needed

Device Compatibility

Must verify whether the current device supports the target Filter

SDK automatically returns only Filters supported by the current device

Filter Selection

Fully independent selection

Determined by SDK based on device model

Default Parameters

Must set appropriate values manually

Already the optimal configuration for the current device

Typical Scenarios

Product customization, algorithm tuning

Quick integration, general-purpose demos

Recommendations

• If you are a first-time user or just want to see results quickly, use the Recommended Filter List. It takes only a few lines of code to get started.

• If you need to select a specific Filter combination or have precise parameter requirements, use Create Filter Directly.

• The two approaches can be combined: first use the recommended list to learn which Filters your device supports, then create them directly for fine-grained parameter tuning.

ON THIS PAGE

Add

  • Name:

  • Link Address:

Cancel

Add

  • Name:

  • Link Address:

Cancel
Questions or
Feedback?

Feedback

  • Your feedback matters! Share your thoughts on this page, report errors, or let us know how we can improve to better support your needs. If applicable, please include the specific sentence or section to help us identify and address the issue.